home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / util / misc / Fudgit233.lha / Source / src / strings.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-14  |  1.4 KB  |  77 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #ifndef NOUNISTD_H
  4. #include <unistd.h>
  5. #endif
  6. #include "fudgit.h"
  7. #include "head.h"
  8.  
  9. extern void Ft_matherror(char *, char *, int);
  10.  
  11. char *Ft_Read(void)
  12. {
  13.     static char realine[TOKENSIZE+4];
  14.     extern char Ft_Inname[];
  15.     extern FILE *Ft_Inread;
  16.  
  17.     realine[TOKENSIZE+3] = '\0';
  18.     if (Ft_Inread == stdin) {
  19.         fputs("Read? ", stderr);
  20.         while (fgets(realine, TOKENSIZE, Ft_Inread) == NULL) {
  21.             fputs("\nRead? ", stderr);
  22.         }
  23.     }
  24.     else {
  25.         if (fgets(realine, TOKENSIZE, Ft_Inread) == NULL) {
  26.             fprintf(stderr, "Read: Reached end of file \"%s\".\n",
  27.             Ft_Inname);
  28.             strcpy(Ft_Inname, "stdin");
  29.             Ft_Inread = stdin;
  30.             Ft_matherror("Resetting input to stdin...", NULL, 0);
  31.         }
  32.     }
  33.     realine[strlen(realine)-1] = '\0';
  34.     return(realine);
  35. }
  36.  
  37. char *Ft_Scan(char *s1, char *s2)
  38. {
  39.     static char scanline[TOKENSIZE+4];
  40.  
  41.     if (sscanf(s1, s2, scanline) != 1) {
  42.         fprintf(stderr, "Scan: Wrong assignment \"%s\".\n", s2);
  43.         Ft_catcher(ERRR);
  44.     }
  45.     scanline[TOKENSIZE+3] = '\0';
  46.     return(scanline);
  47. }
  48.  
  49. char *Ft_FileName(char *s)
  50. {
  51.     register char *cp;
  52.  
  53.     cp = s;
  54.     while (*cp)
  55.         cp++;
  56.     while (cp >= s && *cp != '/')
  57.         cp--;
  58.     cp++;
  59.     return(cp);
  60. }
  61.  
  62. char *Ft_DirName(char *s)
  63. {
  64.     static char dirname[TOKENSIZE+4];
  65.     register char *cp;
  66.  
  67.     cp = dirname;
  68.     strcpy(dirname, s);
  69.     while (*cp)
  70.         cp++;
  71.     while (cp > dirname && *cp != '/')
  72.         cp--;
  73.     *cp = '\0';
  74.     return(dirname);
  75. }
  76.  
  77.